package com.sxf.controller;

import cn.hutool.core.date.DateUtil;
import com.sxf.cache.Ehcache2Cache;
import com.sxf.utils.YtUtil;
import net.sf.ehcache.Cache;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;

/**
 * @author Author
 * @version 1.0
 * @description
 * @date 2024/3/5 11:07:05
 */
@RequestMapping()
public class TestController {
    public static void main(String[] args) {
        TestController testController = new TestController();
//        System.out.println("hello");
//        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>");
//        testController.testCache();
//        System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<");
//        testController.testDate();
//        System.out.println("now is " + new Date());
        testController.test3();
    }

    public void test3(){
        String mobile_reg="^1[0-9]{10}$";
        String mobile_reg2="/^1[3|4|5|7|8][0-9]{9}$/";
        String mobile_reg3="^[0-9]{11}$";
        if (YtUtil.validStrPattern(mobile_reg,"18833481639")) {
            System.out.println("valid");
        }

    }

    public  void testCache(){
        Cache tokenCache = Ehcache2Cache.initCache("token");
//        tokenCache.put(new Element("1234","zhangsan"));
        System.out.println(tokenCache.get("1234"));
//        System.out.println(tokenCache.getCacheConfiguration().getTimeToLiveSeconds());
    }

    public void testDate(){

        Date date1 = DateUtil.beginOfDay(new Date());
        System.out.println("date1 is " +  DateUtil.format(date1,"yyyy-MM-dd HH:mm:ss"));
        Date date2 = DateUtil.parseDate("2024-04-05 00:00:00");
        if (date2.after(date1)) {
            System.out.println("date2 before date1");
        }else{
            System.out.println("date2 after date1");
        }
    }


}
